home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C# & Game Programming - A…er's Guide (2nd Edition)
/
Buono 2nd Ed.iso
/
GameClasses
/
GameState.cs
< prev
next >
Wrap
Text File
|
2004-09-07
|
2KB
|
57 lines
/* GameState.cs: Contains the GameState class which is responsible for
* maintaining simple state information about a game such as the speed,
* state (started, stopped, etc) and mode (demo, single player, etc.).
*/
using System;
namespace GameClasses {
public class GameState {
// Different speeds the game can be run in.
public const int SPEED_MINIMUM = 1;
public const int SPEED_DEFAULT = 3;
public const int SPEED_MAXIMUM = 10;
// Different "states" the game can be in.
public enum State : int {
Unknown = 0,
Started = 1,
Stopped = 2,
}
// Different "modes" the game can be run in.
[Flags]
public enum Mode : int {
Normal = 0,
SinglePlayer = 0,
TwoPlayer = 1,
Demo = 2,
}
// Member variables
public int currentSpeed;
public State currentState;
public Mode currentMode;
// Constructors
public GameState() {
currentSpeed = SPEED_DEFAULT;
currentState = State.Stopped;
currentMode = Mode.Normal;
}
public GameState(int initialSpeed, State gameState) {
currentSpeed = initialSpeed;
currentState = gameState;
currentMode = Mode.Normal;
}
public GameState(int initialSpeed, State gameState,
Mode gameMode) {
currentSpeed = initialSpeed;
currentState = gameState;
currentMode = gameMode;
}
}
}